import useReplaceContentFormStore from '@renderer/store/Form/ReplaceContentFormStore'

// 查找内容和替换内容
export default function useReplaceContentTransfer(
  callback: () => ITableDataItem[]
) {
  const replaceContentTransfer = () => {
    const { searchContentText, replaceContentText } =
      useReplaceContentFormStore()

    if (searchContentText && replaceContentText) {
      callback().forEach((item) => {
        item.newest.name = item.newest.name.replaceAll(
          searchContentText,
          replaceContentText
        )
      })
    }
  }

  return {
    replaceContentTransfer
  }
}
